home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / FUTILS / FWRITE.DOC < prev    next >
Text File  |  1989-02-23  |  8KB  |  263 lines

  1.                              /\ RKCP /\
  2.                              \/ RKCP \/
  3.  
  4. ********************************************************************
  5. ************************ FWRITE by Rex Kerr ************************
  6. ************************ Copyright (C) 1989 ************************
  7. ********************************************************************
  8.  
  9. This is a Turbo Pascal 5.0 unit written mostly in assembly
  10. language.  It has 12 routines for reading/writing and 7 that
  11. affect how the 12 other routines work.
  12.  
  13. ***
  14.  
  15. VramCh(x,y : byte; ch : char; attr : byte);
  16.  
  17. This writes the character ch in attribute attr at X,Y on the screen.
  18. Note that VramCh pays no attention to any windows that might be
  19. on the screen--all coordinates are absolute screen coordinates.
  20. If you use the CRT unit in your program, you can write in the
  21. current text color using the CRT variable TextAttr (like this:)
  22.  
  23. vramch(xpos,ypos,ch,textattr);  { Only textattr needs to stay the same
  24.                                   to write in TP's text color }
  25.  
  26. ***
  27.  
  28. GetVramCh(x,y : byte; var ch : char; attr : byte);
  29.  
  30. This reads the character and attribute at X,Y.  See VramCh.
  31.  
  32. ***
  33.  
  34. VramCharRpt(count : byte; x,y : byte; ch : char; attr : byte);
  35.  
  36. This works about the same as
  37.  
  38. procedure false_vramcharrpt(count,x,y : byte; ch : char; attr : byte);
  39. var i : integer
  40. begin
  41.      for i := 1 to count do vramch(x,y,ch,attr);
  42. end;
  43.  
  44. except that VramCharRpt is much faster.
  45.  
  46. ***
  47.  
  48. VramLineCopy(count : byte; x,y : byte; x2,y2 : byte);
  49.  
  50. This copies count characters (and attributes) starting at X,Y
  51. and going to X2,Y2.  It works about the same as
  52.  
  53. procedure false_vramlcopy(count,x,y,x2,y2 : byte);
  54. var i,atr : byte;
  55.     ch : char;
  56. begin
  57.      for i := 0 to count-1 do
  58.      begin
  59.           getvramch(x+i,y,ch,attr);
  60.           vramch(x2+i,y2,ch,attr);
  61.      end;
  62. end;
  63.  
  64. except it is much much faster.
  65.  
  66. ***
  67.  
  68. VramWrit(x,y : byte; attr : byte; st : string);
  69.  
  70. This writes the string st in attribute attr starting at X,Y.
  71.  
  72. It will NOT scroll the screen up when it goes off the end of the
  73. last line.
  74.  
  75. ***
  76.  
  77. ClrVramLine(line : byte; attr : byte);
  78.  
  79. This clears the line specified with the attribute specified.
  80.  
  81. ***
  82.  
  83. ClrVram(attr : byte);
  84.  
  85. This clears the screen with the attribute specified.
  86.  
  87. ***
  88.  
  89. VramScroll(lines : shortint; x,y,w,h : byte; attr : byte);
  90.  
  91. This scrolls the defined window (that is, a window the same size as
  92. you would get with window(x,y,w,h); ) up the indicated number of
  93. lines.  New lines will be blank in the attribute attr.  To scroll
  94. the screen down, pass a negative number.
  95.  
  96. Note:  To save speed, scroll as many lines as possible at one time.
  97.  
  98. Instead of writing
  99.  
  100. vramscroll(1,1,1,80,25,7);
  101. vramwrit(1,25,7,'This is the');
  102. vramscroll(1,1,1,80,25,7);
  103. vramwrit(1,25,7,'slow way to');
  104. vramscroll(1,1,1,80,25,7);
  105. vramwrit(1,25,7,'scroll this.');
  106.  
  107. you should write
  108.  
  109. vramscroll(3,1,1,80,25,7);
  110. vramwrit(1,23,7,'This is the');
  111. vramwrit(1,24,7,'fast way to');
  112. vramwrit(1,25,7,'do this.');
  113.  
  114. ***
  115.  
  116. VramLine(x,y : byte; start,count : byte; var lin);
  117.  
  118. This is meant to write count chars and attrs (starting at X,Y on the
  119. screen and start in lin) from the predefined type, vram_line, which
  120. is defined as:
  121.  
  122. type vram_line = array[1..80][1..2] of byte;
  123.  
  124. in FWRITE.
  125. However, you can pass any variable you want...but be sure you don't
  126. overrun it.
  127.  
  128. ***
  129.  
  130. GetVramLine(x,y : byte; start,count : byte; var lin);
  131.  
  132. This does the same thing as VramLine, except it reads into lin
  133. instead of writing from it.
  134.  
  135. ***
  136.  
  137. PutVramSec(var scrn; x,y,w,h : byte; x2,y2 : byte);
  138.  
  139. This is meant to copy a window on the screen (x,y,w,h) from scrn
  140. (starting at x2,y2 in scrn).  It is best explained through a demo,
  141. so try running ftpudemo.exe.
  142.  
  143. ***
  144.  
  145. GetVramSec(var scrn; x,y,w,h : byte; x2,y2 : byte);
  146.  
  147. This is putvramsec's twin.  It does the same as putvramsec, except
  148. it reads from the screen instead of writes to it.
  149.  
  150. ***
  151.  
  152. Get_Display(var screenseg : word);
  153.  
  154. This returns $B000 if the monitor is monochrome, otherwise it
  155. assumes CGA and returns $B800.  It is normally used on the
  156. variable Vid_Mem_Start.  You can set Vid_Mem_Start yourself if
  157. you want to write to an EGA or VGA display, for example.
  158.       Card             Segment
  159.      Monochrome         $B000
  160.      CGA                $B800
  161.      EGA                $A000
  162.      VGA                $A000
  163.  
  164. ***
  165.  
  166. SetVramOfs(ofst : word);
  167.  
  168. This sets the offset of screen memory.  For the real screen, it
  169. should always be 0.  However, you may want to define a "fake" screen.
  170. Assuming FakeBuf is an array at least 4000 bytes long, you can do
  171. this to set up a fake screen to read from and write to:
  172.  
  173.      vid_mem_start := seg(fakebuf);
  174.      setvramofs(ofs(fakebuf));
  175.  
  176. Now, all reads and writes will be to and from fakebuf, just like it
  177. was the real screen.  To write back to the old screen (assuming
  178. Get_Display works for you) you simply do:
  179.  
  180.      get_display(vid_mem_start);
  181.      setvramofs(0);
  182.  
  183. If get_display doesn't work, you'll have to save the old mode in
  184. a variable:
  185.  
  186. var a : word;
  187.     b : vram_scrbuf;
  188.  
  189. begin
  190.      vid_mem_start := $A000;   { You have an EGA in this example }
  191.      ( . . . )                 { Do some stuff                   }
  192.      a := vid_mem_start;       { Save the address                }
  193.      vid_mem_start := seg(b);  { Set the segment address         }
  194.      setvramofs(ofs(b));       { Set the offset address          }
  195.      ( . . . )                 { Write to b instead of screen    }
  196.      vid_mem_start := a;       { Get the old address back again  }
  197.      setvramofs(0);            { Now you can write to the screen }
  198. end.
  199.  
  200. ***
  201.  
  202. GetVramOfs : word;
  203.  
  204. This gets the currently set offset.  I never use this myself, but it
  205. might be useful.
  206.  
  207. ***
  208.  
  209. SetVramMaxX(lines : byte);
  210.  
  211. This sets the length of the lines on the screen.  Useful for both
  212. "fake" screens which are smaller (50*20, maybe) or EGA and VGA modes
  213. where the lines are longer than normal.
  214.  
  215. ***
  216.  
  217. GetVramMaxX : byte;
  218.  
  219. This gets the set length of the lines on the screen.
  220.  
  221. ***
  222.  
  223. SetVramMaxY(lines : byte);
  224.  
  225. This sets the length of the screen in lines.  It isn't really used
  226. except in ClrVram.  The others never check to see if they are going
  227. off the end of the screen.
  228.  
  229. ***
  230.  
  231. GetVramMaxY : byte;
  232.  
  233. This gets the set length of the screen in lines.
  234.  
  235. ***
  236.  
  237. Two warnings:
  238.  
  239. 1) FWRITE will cause snow on snowy CGAs.  I haven't yet found out
  240. how to not cause snow and not slow down good monitors too much.
  241. 2) FWRITE never checks to see that you have valid parameters.  If
  242. your screen is 80*25 and to do vramch(90,30,ch,textattr), It will
  243. write the character out anyway.  This is usually fine for the real
  244. screen.  However, when you are writing to a "fake" screen, you have
  245. to be careful, because if you run over the end of the buffer, you
  246. will most likely be overwriting something you didn't want to.
  247.  
  248. Also note that FWRITE never moves the cursor, and always reads from
  249. absolute screen coordinates (i.e. 1,1 is always the top left corner
  250. of the screen, even if you have done window(20,5,60,20)).
  251.  
  252. This is version 0.7 of FWRITE.  It hasn't made it to 1.0 yet
  253. because it still causes snow (I think) and can't detect EGA or
  254. VGA.
  255.  
  256. If I've neclected to mention something, or if anything is unclear,
  257. please contact using either EasyPlex or BPROGA's TP5 message
  258. section.
  259.  
  260. Rex Kerr  71550,3147
  261.  
  262.                              /\ RKCP /\
  263.                              \/ RKCP \/